<?php
        	
namespace Addons\WXCoupon\Model;
use Home\Model\WeixinModel;
        	
/**
 * WXCoupon的微信模型
 */
class WeixinAddonModel extends WeixinModel{
	function reply($dataArr, $keywordArr = array()) {
		$config = getAddonConfig ( 'WXCoupon' ); // 获取后台插件的配置参数	
		//dump($config);

	}

    //卡卷通过审核
    public function card_pass_check($dataArr){
        $data['time'] = $dataArr['CreateTime'];
        $data['cardid'] = $dataArr['CardId'];

        $token = get_token();
        $access_token = get_access_token($token);
        $url = 'https://api.weixin.qq.com/card/get?access_token=' . $access_token;
        $data = array('card_id'=>$data['cardid']);
        $res = JsonPost($url, json_encode($data));
        $resarr = json_decode($res, true);
        if($resarr['card']){
            $data['cardname'] = $resarr['card'][strtolower($resarr['card']['card_type'])]['base_info']['title'];
        }
        M('yhcard_info')->add($data);
    }

    //卡卷未通过审核
    public function card_not_pass_check(){
        return true;
    }

	// 关注公众号事件
	public function subscribe() {
		return true;
	}
	
	// 取消关注公众号事件
	public function unsubscribe() {
		return true;
	}
	
	// 扫描带参数二维码事件
	public function scan() {
		return true;
	}
	
	// 自定义菜单事件
	public function click() {
		return true;
	}	
}
        	